/*

    real entities - a queriable text db

    Copyright (C) 2009 Eugeny Yakimovitch (at) gmail dot com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.    
    
*/

#include "query.h"

namespace fs = boost::filesystem;

rea::query::query (const fs::path &request)
{
  // assume local file system path
  this->parse_dir (request);
}

bool rea::query::where (const char *condition)
{

}

bool rea::query::order (const char *criteria)
{

}

bool rea::query::parse_dir (const fs::path &dir_path)
{
  if ( !fs::exists( dir_path ) ) return false;
  fs::directory_iterator end_itr; // default construction yields past-the-end
  for ( fs::directory_iterator itr( dir_path );
        itr != end_itr;
        ++itr )
  {
    if ( fs::is_directory(itr->status()) )
    {
      if (! this->parse_dir( itr->path()) ) return false;
    }
    else if ( fs::is_regular( itr->status() ) )
    {
          rea::entity entity (itr->path());
          //std::cout << itr->path().filename() << "\n";
    }
  }
  return false;
}
